// import { Message } from 'element-ui';
const mixin = {
  data() {
    return {};
  },
  methods: {
    go(path) {
      this.$router.push(path);
    },
    goBack() {
      this.$router.go(-1);
    },
    $warning(message) {
      this.$message({
        showClose: true,
        message,
        type: "warning"
      });
    },
    $error(message) {
      this.$message({
        showClose: true,
        message,
        type: "error"
      });
    },
    $success(message) {
      this.$message({
        showClose: true,
        message,
        type: "success"
      });
    }
  },
  filters: {
    formatMoney: function(value = 0, len = 2) {
      return value ? value.toFixed(len) : value;
    },
    formatFixed2: function(value = 0) {
      return Math.round(value * 100) / 100;
    },
    formatFloor: function(value = 0) {
      let reg = /^-?\d+$/;
      if (reg.test(value)) return value;
      let s = JSON.stringify(value);
      return s.substring(0, s.indexOf(`.`) + 3);
    }
  }
};

export default mixin;
